#include <sys/sysctl.h>

NSString* getSysInfoByName(char* typeSpecifier)
{
    size_t size;
    sysctlbyname(typeSpecifier, NULL, &size, NULL, 0);
    char *answer = (char *)malloc(size);
    sysctlbyname(typeSpecifier, answer, &size, NULL, 0);
    NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
    free(answer);
    return results;
}

NSString* getDeviceIDString()
{
    return getSysInfoByName("hw.machine");
}

extern "C" {
    char * _getDeviceIDString()
    {
        NSString *str = getDeviceIDString();
        const char * _output = [str UTF8String];
        char* res = (char*)malloc(strlen(_output)+1);
        strcpy(res, _output);
        return res;
    }
}
